#!/bin/bash
changes=`git status -s | grep "^ M"`
check=`echo "$changes" | grep -v /po/`
if [ "$check" != "" ]; then
  echo "Non i18n updates would be committed"
  exit 1
fi

if [[ `echo $changes | grep de_DE` != "" ]]; then
  language="de_DE"
  translator="Carsten Kurz"
elif [[ `echo $changes | grep nl_NL` != "" ]]; then
  language="nl_NL"
  translator="Rob van Nieuwkerk"
elif [[ `echo $changes | grep es_ES` != "" ]]; then
  language="es_ES"
  translator="Manuel AC"
elif [[ `echo $changes | grep sv_SE` != "" ]]; then
  language="sv_SE"
  translator="Adam Klotblixt"
elif [[ `echo $changes | grep fr_FR` != "" ]]; then
  language="fr_FR"
  translator="Thierry Journet"
elif [[ `echo $changes | grep ru_RU` != "" ]]; then
  language="ru_RU"
  translator="Igor Voytovich"
elif [[ `echo $changes | grep uk_UA` != "" ]]; then
  language="uk_UA"
  translator="Igor Voytovich"
elif [[ `echo $changes | grep cs_CZ` != "" ]]; then
  language="cs_CZ"
  translator="Tomáš Begeni"
elif [[ `echo $changes | grep pt_BR` != "" ]]; then
  language="pt_BR"
  translator="Max M. Fuhlendorf"
elif [[ `echo $changes | grep zh_CN` != "" ]]; then
  language="zh_CN"
  translator="Rov (若文)"
elif [[ `echo $changes | grep da_DK` != "" ]]; then
  language="da_DK"
  translator="Anders Uhl Pedersen"
elif [[ `echo $changes | grep pl_PL` != "" ]]; then
  language="pl_PL"
  translator="Mike Mazur"
elif [[ `echo $changes | grep it_IT` != "" ]]; then
  language="it_IT"
  translator="Riccardo Mantani"
else
  echo "Unknown language"
  exit 1
fi

msg="Updated $language translation from $translator."

git diff

echo "OK?"
read yes
if [ "$yes" == "y" ]; then
    git commit -a -m "$msg"
fi
